package com.hdl.servlet.order;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hdl.entity.HdlUser;
import com.hdl.entity.MallOrder;
import com.hdl.service.MallOrderService;
import com.hdl.service.impl.MallOrderServiceImpl;

/**
 * OrderList2Servlet 查询已支付的订单
 * @author Administrator
 *
 */
@WebServlet("/order-2.let")//
public class OrderList2Servlet extends HttpServlet{
	
	private MallOrderService service = new MallOrderServiceImpl();

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		//从session中获取用户信息
		HdlUser user = (HdlUser) req.getSession().getAttribute("user");
		
		//调用业务逻辑层方法
		List<MallOrder> list = service.findAllOrderByUserId(user.getHdlUserId(),2);
		System.out.println(list);
		
		//存储数据
		req.setAttribute("orderList", list);
		
		//请求转发
		req.getRequestDispatcher("/usercenter/order2.jsp").forward(req, resp);
		
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
}
